AC_INIT([Controle: Saúde e Segurança no Trabalho / Alvarás / Licenças], [1.0.1], [sombra@alcionesytes.net],[sco],[http://sco.moodle.iegran.com.br/])
AC_PREREQ([2.50])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([gnu 1.11 -Wall])
AM_INIT_AUTOMAKE([dist-xz])
AC_CONFIG_MACRO_DIR([m4])
m4_pushdef([AC_INCLUDES_DEFAULT], [$1])
AC_COPYRIGHT([Alcione Ferreira])
AC_REVISION([$Revision: 1.0.1 $])

AC_CANONICAL_HOST

LT_INIT([static])
LDFLAGS="-static-libgcc -static-libstdc++ -static $LDFLAGS"
AC_PROG_CXX
AC_LANG([C++])

AC_HEADER_STDC
AC_CHECK_HEADERS([iostream string fstream vector memory])
AC_CHECK_HEADERS([cstdio cstdlib])
PKG_CHECK_MODULES([GTKMM], [gtkmm-2.4 >= 2.10])
PKG_CHECK_MODULES([PNG], [libpng12 >= 1.2])
PKG_CHECK_MODULES([OPENSSL], [openssl >= 0.9.8])

AC_DEFINE([IMG],["img/"],[Diretório Padrão das imagens])
AC_DEFINE([CONF],["db/db.conf"],[Arquivo de Configuração])
AC_CHECK_FILES([src/bibliotecas.h])

AC_TYPE_SIZE_T

LIBEX
LIBBANCOPG
CHECK_OS

AC_SUBST([AM_CXXFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_SUBST([AM_LDADD])

AC_PREFIX_DEFAULT([~/programas/SCO])

AC_ARG_WITH(pghost,
  [AS_HELP_STRING([--with-pghost],[Hostname servidor PostgreSQL])],
  [pghost=$withval],
  [pghost=177.12.169.27]
)
AC_SUBST([PGHOST],[$pghost])

AC_ARG_WITH(pgbanco,
  [AS_HELP_STRING([--with-pgbanco],[Nome da Base de Dados PostgreSQL])],
  [pgbanco=$withval],
  [pgbanco=iegran]
)
AC_SUBST([PGBANCO],[$pgbanco])

AC_ARG_WITH(pguser,
  [AS_HELP_STRING([--with-pguser],[Usuário do PostgreSQL])],
  [pguser=$withval],
  [pguser=iegran]
)
AC_SUBST([PGUSER],[$pguser])

AC_ARG_WITH(pgsenha,
  [AS_HELP_STRING([--with-pgsenha],[Senha do Usuário do PostgreSQL])],
  [pgsenha=$withval],
  [pgsenha='3duc4r&']
)
AC_SUBST([PGSENHA],[$pgsenha])

AH_TOP([
#ifndef __CONFIGB_H__
#define __CONFIGB_H__ 1

#if  defined(__WIN32__) || defined(__WIN__)
#define NO_LINUX 1
#include <windows.h>
#endif
])
AH_BOTTOM([
#ifdef HAVE_IOSTREAM
	#include <iostream>
#endif
#ifdef HAVE_STRING
	#include <string>
#endif
#ifdef HAVE_FSTREAM
	#include <fstream>
#endif
#ifdef HAVE_VECTOR
	#include <vector>
#endif
#ifdef HAVE_MEMORY
	#include <memory>
#endif
#ifdef HAVE_CTIME
	#include <ctime>
#endif
#ifdef HAVE_CSTDIO
	#include <cstdio>
#endif
#ifdef HAVE_CSTDLIB
	#include <cstdlib>
#endif
#ifdef HAVE_CTYPE_H
	#include <ctype.h>
#endif
#ifdef HAVE_LTDL_H
	#include <ltdl.h>
#endif
#ifdef HAVE_DLFCN_H
	#include <dlfcn.h>
#endif
#ifdef HAVE_STDIO_H
	#include <stdio.h>
#endif
#ifdef HAVE_STDLIB_H
	#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
	#include <string.h>
#endif
#ifdef HAVE_HPDF_H
	#include <hpdf.h>
#endif
#ifdef HAVE_ZLIB_H
	#include <zlib.h>
#endif
#ifdef HAVE_CMATH
	#include <cmath>
#endif

#endif /*__CONFIG_H__*/
])

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([db/db.conf sco.menu sco.directory sco.desktop 
	Makefile 
	src/Makefile 
	docs/Makefile
	img/Makefile])

#Depencias estáticas (Bibliotecas)
AC_CONFIG_SUBDIRS([libex libbancopg])

AC_OUTPUT
